<?php


namespace App\Http\Controllers\Api;


use App\Model\Qxlove;
use App\Model\Room;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class QxloveController extends BaseController
{
    protected $model = null;
    protected $roomsModel = null;

    /**
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new Qxlove();
        $this->roomsModel = new Room();
    }

    /**
     * 礼物送出统计
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function giftlog(Request $request)
    {
        $page = $request->get('page', 1);
        $limit = $request->get('limit', 10);
        $data = $this->model->getGiftSendList($page, $limit);
        
        if (!empty($data)) {
            foreach ($data as $k=>$v)
            {
                //查询礼物信息
                $gifinfo = $this->model->getGifInfo($v['gift_id']);
                $data[$k]['giftname'] = $gifinfo['name']; //礼物名称
                $data[$k]['gift_id'] = $v['gift_id']; //礼物id
                $data[$k]['id'] = $page ? ($page * $limit - $limit + $k + 1) : $k;
            }
        }
        $res['data'] = array_values($data);
        return $this->toJson(self::SUCCESS, $res);
    }


}